<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="js/echarts.js"></script>
    <title>Document</title>
  </head>
  <body>
    <div id="main" style="width: 600px; height: 400px"></div>
    <script>
      var myChart = echarts.init(document.getElementById("main"));
      var option = {
        series: [
          {
            type: "graph",
            data: [
              {
                name: "金义选",
                x: 10,
                y: 50,
              },
              {
                name: "陈杨",
                x: 90,
                y: 50,
              },
              {
                name: "徐思巍",
                x: 90,
                y: 100,
              },
              {
                name: "徐子健",
                x: 10,
                y: 100,
              },
            ],
            label: {
              show: true,
            },
            symbolSize: 70,
            // links中关系信息
            links: [
              {
                // 有关系的两者
                source: "金义选",
                target: "陈杨",
                // 关系线的样式设置
                lineStyle: {
                  color: "green",
                  width: 3,
                },
                label: {
                  show: true,
                  formatter: "陈杨喜欢义选",
                },
              },
              {
                source: "徐思巍",
                target: "徐子健",
                // 关系线的样式设置
                lineStyle: {
                  color: "red",
                  width: 3,
                },
                label: {
                  show: true,
                  formatter: "徐子健喜欢徐思巍",
                },
              },
              {
                source: "徐思巍",
                target: "徐子健",
                // 关系线的样式设置
                lineStyle: {
                  color: "red",
                  width: 3,
                },
                label: {
                  show: true,
                  formatter: "徐子健喜欢徐思巍",
                },
              },
              {
                source: "金义选",
                target: "徐子健",
                // 关系线的样式设置
                lineStyle: {
                  color: "red",
                  width: 3,
                },
                label: {
                  show: true,
                  formatter: "金义选喜欢徐子健",
                },
              },
              {
                source: "陈杨",
                target: "徐思巍",
                // 关系线的样式设置
                lineStyle: {
                  color: "red",
                  width: 3,
                },
                label: {
                  show: true,
                  formatter: "陈杨喜欢徐思巍",
                },
              },
            ],
          },
        ],
      };

      myChart.setOption(option);
    </script>
  </body>
</html>
